package com.vr.xuecheng.content.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vr.xuecheng.base.valid.ValidationGroup;
import com.vr.xuecheng.content.mapper.CourseTeacherMapper;
import com.vr.xuecheng.content.model.dto.SaveOrUpdateTeacherDTO;
import com.vr.xuecheng.content.model.entity.CourseTeacher;
import com.vr.xuecheng.content.service.ICourseTeacherService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 * 课程-教师关系表 服务实现类
 * </p>
 *
 * @author hsh
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class CourseTeacherServiceImpl extends ServiceImpl<CourseTeacherMapper, CourseTeacher> implements ICourseTeacherService {
    private final CourseTeacherMapper courseTeacherMapper;

    @Override
    public boolean save(@Validated({ValidationGroup.Insert.class}) SaveOrUpdateTeacherDTO req) {
        return courseTeacherMapper.insert(BeanUtil.toBean(req, CourseTeacher.class))>0;
    }

    @Override
    public boolean updateById(@Validated({ValidationGroup.Update.class}) SaveOrUpdateTeacherDTO req) {
        return courseTeacherMapper.updateById(BeanUtil.toBean(req, CourseTeacher.class))>0;
    }
}
